/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "sle_lite_ut_entry.h"

static CmdNode g_cmdList[] = {
    { "Menu", SleLiteUtMenu},
    { "sle_hdi_unit_test", SleHdiTestEntry},
    { "sle_hal_unit_test", SleHalTestEntry},
    { "kh_sle_c_interface_unit_test", KhSleCInterfaceTestEntry},
};
static uint16_t g_cmdNum = sizeof(g_cmdList) / sizeof(CmdNode);

void SleLiteUtMenu(void)
{
    printf("************hdi_sle_cmd************\r\n");
    for (int i = 0; i < g_cmdNum; i++) {
        printf("%d:%s\r\n", i, g_cmdList[i].desc);
    }
    printf("***************end****************\r\n");
}

void SleLiteUtEntry(int argc, char **argv)
{
    SLE_UT_LOG("SleLiteUtEntry");
    //从函数名字之后开始处理参数列表
    SleSetBufEnv(argc, argv, 1);
    uint16_t index = SleGetInputNumber("Please input cmd index:");
    if(index < g_cmdNum) {
        printf("\r\ncmd: %d\r\n", index);
        printf("\r\nExecute: %s\r\n", g_cmdList[index].desc);
        g_cmdList[index].func();
    }
}

void AppSleLiteUtToolStart(void)
{
    printf("app_SleLiteUtToolStart in\r\n");
    RegisterToolFunction(SleLiteUtEntry, "--sle_lite_ut", "use :[AT+KHCOMMONTOOL=--sle_lite_ut 0] to show menu of sle_lite_ut.");
}